package com.ticket.sass.admin.dto.output.order.group;

import com.ticket.sass.admin.dto.output.order.SessionOutput;
import com.ticket.sass.admin.dto.output.order.TicketOutput;
import com.ticket.sass.common.entity.tenant.OrderGroupPurchaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @author ywb
 * @date 2024-08-14 17:19
 */
@Data
@ApiModel
public class OrderGroupListOutput {
    @ApiModelProperty(value = "ID")
    private Long id;
    
    @ApiModelProperty(value = "订单ID")
    private Long orderId;
    
    @ApiModelProperty(value = "订单号")
    private String orderNo;
    
    @ApiModelProperty(value = "用户ID")
    private Long userId;
    
    @ApiModelProperty(value = "用户名")
    private String username;
    
    @ApiModelProperty(value = "手机号")
    private String cellphone;
    
    @ApiModelProperty(value = "票信息")
    private List<TicketOutput> tickets;
    
    
    @ApiModelProperty(value = "场次信息")
    private SessionOutput session;
    
    @ApiModelProperty(value = "支付价格")
    private BigDecimal payPrice;
    
    @ApiModelProperty(value = "订单备注")
    private String remark;
    
    @ApiModelProperty(value = "退款备注")
    private String refundRemark;
    
    @ApiModelProperty(value = "支付类型：1 微信，2 支付宝，3 会员卡")
    private Short payType;
    
    @ApiModelProperty(value = "支付状态：0 未支付，1 支付中，2 已支付，3 支付失败，4 退款中，5 已退款")
    private Short payStatus;
    
    @ApiModelProperty(value = "排期 id")
    private Long filmScheduleId;
    
    @ApiModelProperty(value = "支付时间")
    private LocalDateTime payTime;
    
    @ApiModelProperty(value = "下单时间")
    public LocalDateTime createdAt;
    
    @ApiModelProperty(value = "购票数量")
    private Integer ticketCount;
    
    
    public OrderGroupListOutput() {
    }
    
    public OrderGroupListOutput(OrderGroupPurchaseEntity entity) {
        this.id = entity.getId();
        this.orderNo = entity.getOrderNo();
        this.orderId = entity.getOrderId();
        
        this.session = new SessionOutput(entity.getSessionStartTime(), entity.getSessionEndTime(), entity.getFilmName(), entity.getHallName(), entity.getFilmLang(), entity.getFilmVersion());


        this.userId = entity.getUserId();

        this.tickets = new ArrayList<>();
        

        this.payPrice = entity.getPayPrice();
        this.remark = entity.getRemark();
        this.payType = entity.getPayType();
        this.payStatus = entity.getPayStatus();
        this.filmScheduleId = entity.getFilmScheduleId();
        this.payTime = entity.getPayTime();
        this.createdAt = entity.getCreatedAt();
        this.ticketCount = entity.getTicketCount();
    }
}
